package org.web.accesscontrollist.demo.controller;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.web.accesscontrollist.sdk.biz.AclResourceDetailBiz;
import org.web.accesscontrollist.sdk.dto.AclResourceDetailDTO;
import org.web.accesscontrollist.sdk.dto.query.QueryAclResourceDetailRequest;
import org.web.base.domain.ResultDO;
import org.web.base.domain.view.ViewResultDTO;

import jakarta.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/hello")
public class HelloController {

    private static final Logger logger = LogManager.getLogger(HelloController.class);

    @Resource
    private AclResourceDetailBiz aclResourceDetailBiz;

    @RequestMapping("sayhelloWorld")
    @ResponseBody
    public String sayHelloWorld(String name) {
        logger.info("name is : " + name);
        System.out.println("hello " + name);
        return "welcome to world, " + name;
    }

    @RequestMapping("selectAclResourceDetailList")
    @ResponseBody
    public ViewResultDTO selectAclResourceDetailList(String name) {
        ViewResultDTO<List<AclResourceDetailDTO>> viewResultDO = new ViewResultDTO<>();
        QueryAclResourceDetailRequest queryAclResourceDetailRequest = new QueryAclResourceDetailRequest();
        queryAclResourceDetailRequest.setPageNum(1);
        queryAclResourceDetailRequest.setPageSize(10);
        ResultDO<List<AclResourceDetailDTO>> resultDO = aclResourceDetailBiz.selectAclResourceDetailList(queryAclResourceDetailRequest);
        viewResultDO.setData(resultDO.getDomain());
        return viewResultDO;
    }

//    @Resource
//    private Config1 config1;
//
//    @RequestMapping("getConfigInfo")
//    @ResponseBody
//    public String getConfigInfo() {
//       Gson gson = new Gson();
//       Map map = new HashMap();
//       map.put("a1", config1.getA1());
//       map.put("a2", config1.getA2());
//       map.put("a3", config1.getA3());
//       map.put("UserConfig", config1.getUserConfig());
//       return gson.toJson(map);
//     }
}
